package edu.xidian.bdilab.jrbigdata.service.government.login.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import edu.xidian.bdilab.jrbigdata.controller.response.ResponseResult;
import edu.xidian.bdilab.jrbigdata.domain.GovernmentUser;
import edu.xidian.bdilab.jrbigdata.mapper.GovermentUserMapper;
import edu.xidian.bdilab.jrbigdata.service.government.login.GovernmentLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class GovernmentLoginServiceImpl implements GovernmentLoginService {
    @Autowired
    GovermentUserMapper govermentUserMapper;
    @Override
   public ResponseResult responsResult(String name, String password)
   {
       QueryWrapper<GovernmentUser> userWrapper = new QueryWrapper<>();
       //UpdateWrapper<Enterpriseuser>updateWrapper=new UpdateWrapper<>();

       userWrapper.eq("user_name",name);

       GovernmentUser person= govermentUserMapper.selectOne(userWrapper);

      if(person==null)
      {
          ResponseResult responseResult = new ResponseResult();
          responseResult.setCode("1002");
          responseResult.setMessage("请注册");
          responseResult.setSuccess(false);
          return responseResult;
      }


      else{
          if(person.getPassword().equals(password))
          {
              ResponseResult responseResult = new ResponseResult();
              responseResult.setCode("1001");
              responseResult.setMessage("登陆成功");
              responseResult.setSuccess(true);
              return responseResult;
          }
          else
          {
              ResponseResult responseResult = new ResponseResult();
              responseResult.setCode("1003");
              responseResult.setMessage("密码错误");
              responseResult.setSuccess(false);
              return responseResult;
          }
      }

   }

}
